package myFileUtils;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author lntrung
 */
public class MyRenderer extends DefaultTableCellRenderer {

//    public JLabel lb = new JLabel();
//    public String path;
//
//    public IconRenderer(String value){
//        path = value;
//        System.out.println(path);
//    }

     public void fillColor(JTable table,JLabel label,boolean isSelected ){
        if(isSelected){
            label.setBackground(table.getSelectionBackground());
            label.setForeground(table.getSelectionForeground());
        }
        else{
            label.setBackground(table.getBackground());
            label.setForeground(table.getForeground());
        }
    }

    @Override
    public Component getTableCellRendererComponent(JTable table,Object value,
                    boolean isSelected, boolean hasFocus, int row, int column) {
        if (value instanceof JLabel){
            JLabel label = (JLabel)value;
            label.setOpaque(true);
            fillColor(table, label, isSelected);
            return label;
        } else {
            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    }
}